#include <iostream>
#include <string>
#include <vector>
#include <unistd.h>
#include "Thread.hpp"

using namespace std;

void Print(int num)
{
    while (num)
    {
        cout << "Hello Linux : " << num-- << endl;
        sleep(1);
    }
}

const int threadnum = 5;
string GetThreadName()
{
    static int num = 1;
    string name = "thread-" + to_string(num++);
    return name;
}

int main()
{
    vector<Thread<int>> threads;
    for (int i = 0; i < threadnum; i++)
    {
        threads.push_back(Thread<int>(GetThreadName(), Print , 10));
    }

    for (auto &t : threads)
    {
        cout << t.ThreadName() << " is running ? " << t.IsRunning() << endl;
    }

    for (auto &t : threads)
    {
        cout << t.ThreadName() << "is start ? " << t.Start() << endl; 
    }

    for (auto &t : threads)
    {
        cout << t.ThreadName() << " is running ? " << t.IsRunning() << endl;
    }

    for (auto &t : threads)
    {
        t.Join();
    }

    return 0;
}